// $codepro.audit.disable numericLiterals
/**
 * Doctors order panel
 */
package edu.gatech.oad.doctorsorder;

import javax.swing.JPanel;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JEditorPane;
import javax.swing.JButton;
import javax.swing.JScrollPane;
import java.awt.GridBagLayout;
import java.awt.GridBagConstraints;
import java.awt.Insets;
import javax.swing.JLabel;
import javax.swing.BoxLayout;

import edu.gatech.oad.ui.UserPanel;

/**
 * User interface to display doctor's order.
 * 
 * @author chen
 * @version 1.0
 */
public class DoctorsOrderPanel extends JPanel {
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	/**
	 * Create the panel.
	 * 
	 * @param order
	 *            the doctor's order to view/edit
	 * @param userPanel
	 *            the panel to display
	 */
	public DoctorsOrderPanel(final DoctorsOrder order, UserPanel userPanel) {
		final GridBagLayout gridBagLayout = new GridBagLayout();
		gridBagLayout.columnWidths = new int[] { 0, 0 };
		gridBagLayout.rowHeights = new int[] { 250, 0, 0 };
		gridBagLayout.columnWeights = new double[] { 1.0, Double.MIN_VALUE };
		gridBagLayout.rowWeights = new double[] { 1.0, 1.0, Double.MIN_VALUE };
		setLayout(gridBagLayout);

		final JPanel note = new JPanel();
		final GridBagConstraints gbc_note = new GridBagConstraints();
		gbc_note.insets = new Insets(0, 0, 5, 0);
		gbc_note.fill = GridBagConstraints.BOTH;
		gbc_note.gridx = 0;
		gbc_note.gridy = 0;
		add(note, gbc_note);
		note.setLayout(new BoxLayout(note, BoxLayout.X_AXIS));

		final JLabel lblNote = new JLabel("Note: ");
		note.add(lblNote);

		final JScrollPane noteInputPanel = new JScrollPane();
		note.add(noteInputPanel);

		final JEditorPane noteInputArea = new JEditorPane();
		noteInputPanel.setViewportView(noteInputArea);

		final JPanel btnPanel = new JPanel();
		final GridBagConstraints gbc_btnPanel = new GridBagConstraints();
		gbc_btnPanel.fill = GridBagConstraints.BOTH;
		gbc_btnPanel.gridx = 0;
		gbc_btnPanel.gridy = 1;
		add(btnPanel, gbc_btnPanel);

		final JButton btnSave = new JButton("save");
		btnSave.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				order.setNotes(noteInputArea.getText());

			}
		});
		btnPanel.add(btnSave);
	}

}
